import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Login from '@/pages/login'

const home = r => require.ensure([], () => r(require('@/pages/layout/Layout')), 'home');

export const constantRouterMap = [
  {
    path: '/',
    component: home,
    redirect: '/dashboard',
    // name: 'Dashboard',
    // hidden: true
  },
  {
    path: '/lottery1',
    component: home,
    children: [
      {
        path: '',
        component: () => import('@/components/scrollv2.vue')
      }
    ]
  },
  {
    path: '/lottery2',
    component: home,
    children: [
      {
        path: '',
        component: () => import('@/components/scrollv3.vue')
      }
    ]
  },
  {
    name: "login",
    path: '/login',
    component: Login,
  },
  {
    path: '/datasearch',
    component: home,
    children: [
      {
        path: '',
        name: 'datasearch',
        component: () => import('@/pages/datasearch')
      }
    ]
  },
  {
    path: '/dashboard',
    component: home,
    children: [
      {
        path: '',
        name: 'dashboard',
        component: () => import('@/pages/dashboard')
      }
    ]
  },
  {
    path: '/upload',
    component: home,
    children: [
      {
        path: '',
        name: 'upload',
        component: () => import('@/components/Upload/index')
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/pages/errPage/404'),
    hidden: true
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  { path: '*', redirect: '/404', hidden: true }
]